<?php
//echo sqrt(9), "\n"; //开平方
//echo cos(60*pi()/180), "\n"; //余弦，参数的单位是弧度
//echo cos(deg2rad(60)), "\n"; //度转换为弧度
//echo pow(3,2), "\n";  //3的平方
//echo round(3.1415926,1), "\n"; //保留1位小数
//echo round(3.1415926,3), "\n"; //保留3位小数


echo "已知三角形的边角边，计算对边\n";
echo "请输入三角形的边角边，各数据间用逗号分隔开来：\n";
$count = fscanf(STDIN, "%f ,%f ,%f %s", $a, $beta, $b, $others);
//echo "count=$count, a=$a, b=$b, beta=$beta, others=$others\n";
if ($count > 3) {// 用户输入的数据后边有多余的东西
    echo "输入的数据后边不要加多余的乱七八糟的东西~\n\n";
} else if ($count < 3) {
    echo "数据输入有误， 请根据提示按格式输入数据~\n";
}else {
    $c = round(sqrt($a * $a + pow($b, 2) - 2 * $a * $b * cos($beta * pi() / 180)), 2);
    echo "三角形对边的长度 = $c\n";
}
